< previous page page_584 next page >

Page 584
(table continued from previous page)
Method NameDescription
ExistsReturns a True value if the key name exists underneath a specified section
SectionGetRetrieves all the key names and key values from a specified section and returns them in a Variant array

Class Initialization
When you create an instance of the INI class, the Class_Initialize() event automatically sets the ConfigName property to the name of the EXE file for your project. For example, if your project name is Emps, the INI name will be Emps.ini. Class_Initialize() looks for the INI file in the same directory where the EXE is located. This avoids you having to pass in the INI filename to the class. Of course, you can always pass this information in if you want to store the INI file in another location. Heres the Class_Initialize() event for the INI class:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub Class_Initialize()
   mstrConfigName = App.Path & "\" & _
                   App.EXEName & ".ini"
End Sub
Using the INI Class to Get Data
If you click the Get W/Class command button in the sample form, youll see that information can be retrieved from the INI file. The Click event for this command button instantiates an instance of the INI class. Set the values from the text boxes and then invoke the KeyGet() method to retrieve the data. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdGetClass_Click()
   Dim oIni As INI

   Set oIni = New INI
   With oIni
      .ConfigName = Trim$(txtConfig)
      .Section = Trim$(txtSection)
      .KeyName = Trim$(txtKeyName)
      txtKeyValue = .KeyGet
   End With

 
< previous page page_584 next page >

If you like this book, buy it!